export default {
	data() {
		return {
			searchText: '',
			historyArr: [],
		};
	},
	onLoad(options) {
		this.type = options.type || ''
		if (!this.$isEmpty(this.$store.get('history'))) {
			this.historyArr = this.$store.get('history').split(',')
		} else {
			this.historyArr = []
		}
	},
	methods: {
		// 输入搜索
		onSearch() {
			if (this.historyArr.indexOf(this.searchText) == -1 && this.searchText != '') {
				this.historyArr.push(this.searchText)
				this.$store.set('history', this.historyArr.toString())
			}
			this.$redirectTo('pages/manghe/search-info/search-info', {
				searchText: this.searchText
			})
			// this.onBackSearch()
		},
		// 点击历史搜索
		onHistoryClick(item) {
			this.searchText = item
			this.$redirectTo('pages/manghe/search-info/search-info', {
				searchText: this.searchText
			})
			// this.onBackSearch()
		},
		// 清除历史记录
		onDelect() {
			var self = this
			this.$showModal({
				title: '提示',
				content: '确认删除历史记录？',
				success(res) {
					if (res.confirm) {
						console.log('用户点击确定')
						self.historyArr = []
						self.$store.remove('history')
					} else if (res.cancel) {
						console.log('用户点击取消')
					}
				}
			})
		},
		// 搜索取消
		onCancel() {

		},
		// 搜索清除
		onClear() {

		}
	}
}
